package main

//#link: https://leetcode-cn.com/problems/symmetric-tree/
func main() {

}

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

/**
 * @Description: 给定一个二叉树，检查它是否是镜像对称的。
 */
func isSymmetric(root *TreeNode) bool {
	return isRepeat(root, root)
}

/**
 * @Description: 递归比较左子树的左节点和右节点是否相等
 */
func isRepeat(left, right *TreeNode) bool {
	if left == nil || right == nil {
		return left == right
	}
	return isRepeat(left.Left, right.Right) && left.Val == right.Val && isRepeat(left.Right, right.Left)
}
